<template>
  <view :style="themeColor">
    <view class="page">
      <view
        class="flex flex-direction flex-wrap align-stretch benben-position-layout flex managingpersonalInformation_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub managingpersonalInformation_fd0_0'>
          <view class='flex flex-wrap align-center managingpersonalInformation_fd0_0_c0' @tap.stop="handleJumpDiy"
            data-type="back" data-url="1">
            <text class='fu-iconfont2  managingpersonalInformation_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='managingpersonalInformation_fd0_0_c1_c0'>加入粮站</text>
          </view>
          <view class='flex flex-wrap align-center justify-end managingpersonalInformation_fd0_0_c0'>
            <image class='managingpersonalInformation_fd0_0_c2_c0' mode="aspectFit" :src='STATIC_URL+"7.png"'></image>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout">
        <view class='flex flex-wrap align-center managingpersonalInformation_fd1_0'>
          <text class='managingpersonalInformation_fd1_0_c0'>最后一步</text>
        </view>
        <view class='flex flex-direction flex-wrap align-stretch managingpersonalInformation_fd1_1'>
          <view class='flex flex-direction flex-wrap align-start managingpersonalInformation_fd1_1_c0'>
            <text class='managingpersonalInformation_fd1_1_c0_c0'>姓名</text>
            <benben-input class='managingpersonalInformation_fd1_1_c0_c1' type="text" :placeholder="`请输入姓名`"
              confirm-type="done" :maxlength="10" v-model="xingming" placeholder-style="color:#999;font-size:36rpx" />
          </view>
          <view class='flex flex-direction flex-wrap align-start managingpersonalInformation_fd1_1_c0'>
            <text class='managingpersonalInformation_fd1_1_c0_c0'>联系电话</text>
            <benben-input class='managingpersonalInformation_fd1_1_c0_c1' type="number" :placeholder="`请输入联系电话`"
              confirm-type="done" :maxlength="11" v-model="lianxidianhua"
              placeholder-style="color:#999;font-size:36rpx" />
          </view>
          <view class='flex flex-direction flex-wrap align-stretch managingpersonalInformation_fd1_1_c0'>
            <text class='managingpersonalInformation_fd1_1_c0_c0'>粮站名称</text>
            <benben-input class='managingpersonalInformation_fd1_1_c0_c1' type="text" :placeholder="`请输入粮站名称`"
              confirm-type="done" :maxlength="10" v-model="mingcheng" placeholder-style="color:#999;font-size:36rpx" />
          </view>
          <view class='flex flex-direction flex-wrap align-start managingpersonalInformation_fd1_1_c0'>
            <text class='managingpersonalInformation_fd1_1_c0_c0'>经营年限</text>
            <benben-input class='managingpersonalInformation_fd1_1_c0_c1' type="number" :placeholder="`请输入经营年限`"
              v-model="jingyingnianxian" confirm-type="done" :maxlength="5"
              placeholder-style="color:#999;font-size:36rpx" />
          </view>
          <view class='flex flex-direction flex-wrap align-stretch managingpersonalInformation_fd1_1_c0'>
            <view class='flex flex-wrap align-center'>
              <text class='managingpersonalInformation_fd1_1_c4_c0_c0'>粮站招牌</text>
              <text class='managingpersonalInformation_fd1_1_c4_c0_c1'>请上传图片</text>
            </view>
            <view class='flex flex-wrap align-center managingpersonalInformation_fd1_1_c4_c1'>
              <view class='flex flex-direction flex-wrap align-stretch'>
                <benben-images-upload ref="benbenImagesUploadfd1_0_c4_c01" :maxlength="1"
                  :img-list.sync="zhaopaifengmian" :img-ids.sync="img_ids" :is-show-tips='true'>
                  <template #content="{ num, maxlength, isShow, imgList }">
                    <view class="flex flex-wrap align-start flex feedBack_fd1_0_c4_c0">

                      <view v-for="(image, index) in imgList" :key="index"
                        class='flex position-relative feedBack_fd1_0_c4_c00'>
                        <text class='fu-iconfont2 position-absolute feedBack_fd1_0_c4_c000'
                          @tap.stop="$refs.benbenImagesUploadfd1_0_c4_c01.delImage(index)">&#xE8E7;</text>
                        <image class='feedBack_fd1_0_c4_c001'
                          @tap.stop="$refs.benbenImagesUploadfd1_0_c4_c01.previewImage(index)" mode="aspectFill"
                          :src='image'>
                        </image>
                      </view>

                      <image class='feedBack_fd1_0_c4_c01'
                        @tap.stop="$refs.benbenImagesUploadfd1_0_c4_c01.manyChooseImage()" v-if="isShow"
                        mode="aspectFit" :src='STATIC_URL+"25.png"'></image>

                    </view>
                  </template>
                </benben-images-upload>
              </view>
            </view>
          </view>
          <view class='flex flex-direction flex-wrap align-stretch managingpersonalInformation_fd1_1_c5'>
            <view class='flex flex-wrap align-center'>
              <text class='managingpersonalInformation_fd1_1_c4_c0_c0'>粮站环境</text>
              <text class='managingpersonalInformation_fd1_1_c4_c0_c1'>亲！上传真实粮站图片，会更吸引客户呦！</text>
            </view>
            <view class='flex flex-direction flex-wrap align-stretch'>
              <benben-images-upload ref="benbenImagesUploadfd1_0_c4_c0" :maxlength="6"
                :img-list.sync="liangzhanhuanjing" :img-ids.sync="img_id" :is-show-tips='true'>
                <template #content="{ num, maxlength, isShow, imgList }">
                  <view class="flex flex-wrap align-start flex feedBack_fd1_0_c4_c0">

                    <view v-for="(image, index) in imgList" :key="index"
                      class='flex position-relative feedBack_fd1_0_c4_c00'>
                      <text class='fu-iconfont2 position-absolute feedBack_fd1_0_c4_c000'
                        @tap.stop="$refs.benbenImagesUploadfd1_0_c4_c0.delImage(index)">&#xE8E7;</text>
                      <image class='feedBack_fd1_0_c4_c001'
                        @tap.stop="$refs.benbenImagesUploadfd1_0_c4_c0.previewImage(index)" mode="aspectFill"
                        :src='image'>
                      </image>
                    </view>

                    <image class='feedBack_fd1_0_c4_c01'
                      @tap.stop="$refs.benbenImagesUploadfd1_0_c4_c0.manyChooseImage()" v-if="isShow" mode="aspectFit"
                      :src='STATIC_URL+"25.png"'></image>

                  </view>
                </template>
              </benben-images-upload>
            </view>
          </view>
          <view class='flex flex-wrap align-center managingpersonalInformation_fd1_1_c6'>
            <button class='managingpersonalInformation_fd1_1_c6_c0' @tap.stop="submit" data-type="navigateTo"
              :data-url="`/pages/wode/personalinformationSuccessfully/personalinformationSuccessfully`">确定</button>
          </view>
        </view>
      </view>

      <!---flex布局flex布局结束-->


    </view>
  </view>
</template>
<script>
  import UploadImage from '@/common/utils/upload-image.js';
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "fd1_1_c4_c1_c0": "",
        "fd1_1_c4_c1_c0id": "",
        "fd1_1_c5_c1_c0": "",
        "fd1_1_c5_c1_c0id": "",
        "img": [],
        "img_id": '',
        img_ids: '',
        jingdu: '',
        weidu: '',
        liangzhancate_id: '',
        liangzhanshebeicate_id: '',
        xingming: '',
        lianxidianhua: '',
        jingyingnianxian: '',
        liangzhanhuanjing: [],
        zhaopaifengmian: [],
        mingcheng: '',
        chengshi: '',
        shengfen: '',
        weizhi: '',
        submitobj: {
          jingdu: '',
          weidu: '',
          liangzhancate_id: '',
          liangzhanshebeicate_id: '',
          xingming: '',
          lianxidianhua: '',
          jingyingnianxian: '',
          liangzhanhuanjing: [],
          zhaopaifengmian: [],
          mingcheng: '',
          chengshi: '',
          shengfen: '',
          weizhi: '',
        },
        chengshi: '',
        shengfen: '',
        weizhi: ''
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      this.submitobj = JSON.parse(options.objs)
      console.log(' this.submitobj', this.submitobj)
      this.getLocation()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      getLocation() {
        this.$api.post(global.apiUrls.post65def35265135, {
          location: this.submitobj.jingdu + ',' + this.submitobj.weidu
        }).then(res => {
          if (res.data.code == 1) {
            console.log('ppp0,weizhi', res.data.data)
            this.chengshi = res.data.data.all.city
            this.shengfen = res.data.data.all.province
            this.weizhi = this.chengshi + this.shengfen + res.data.data.all.township

          }
        })
      },
      submit() {
        console.log('this.submitobj.xingming', this.xingming)
        if (!this.xingming) {
          this.$message.info('请输入姓名')
          return;
        }
        if (!this.lianxidianhua) {
          this.$message.info('请输入联系电话')
          return;
        }
        if (!validate(this.lianxidianhua, 'phone')) {
          this.$message.info('请输入正确的手机号');
          return false;
        }
        if (!this.mingcheng) {
          this.$message.info('请输入粮站名称')
          return;
        }
        if (!this.jingyingnianxian) {
          this.$message.info('请输入经营年限')
          return;
        }
        if (this.zhaopaifengmian.length == 0) {
          this.$message.info('请上传相关粮站照片')
          return;
        }
        if (this.liangzhanhuanjing.length == 0) {
          this.$message.info('请上传相关粮站照片')
          return;
        }
        // this.submitobj.xingming = this.xingming
        // this.submitobj.lianxidianhua = this.lianxidianhua
        // this.submitobj.mingcheng = this.mingcheng
        // this.submitobj.jingyingnianxian = this.jingyingnianxian
        // this.submitobj.weizhi = this.weizhi
        // this.submitobj.shengfen = this.shengfen
        // this.submitobj.chengshi = this.chengshi
        this.liangzhanhuanjing = this.liangzhanhuanjing.join(',')
        this.zhaopaifengmian = this.zhaopaifengmian.join(',')
        this.$api.post(global.apiUrls.post65d83e1a961bb, {
          jingdu: this.submitobj.jingdu,
          weidu: this.submitobj.weidu,
          liangzhancate_id: this.submitobj.liangzhancate_id,
          liangzhanshebeicate_id: this.submitobj.liangzhanshebeicate_id,
          xingming: this.xingming,
          lianxidianhua: this.lianxidianhua,
          jingyingnianxian: this.jingyingnianxian,
          liangzhanhuanjing: this.liangzhanhuanjing,
          zhaopaifengmian: this.zhaopaifengmian,
          mingcheng: this.mingcheng,
          chengshi: this.chengshi,
          shengfen: this.shengfen,
          weizhi: this.weizhi,
        }).then(res => {
          if (res.data.code == 1) {

            if (res.data.data.is_vip == false) {
              // uni.redirectTo({
              //   url: `/pages/wode/personalinformationSuccessfully/personalinformationSuccessfully?aid=${res.data.data.liangzhan_id}`
              // })
              uni.redirectTo({
                url: `/pages/wode/rurchaseMembership/rurchaseMembership`
              })
            } else {
              console.log('res.data.data111', res.data.data.is_vip)
              uni.redirectTo({
                url: `/pages/wode/mygrainStation/mygrainStation`
              })
            }
          } else {
            this.$message.info(res.data.msg)
          }
        })
      },
    }
  };
</script>
<style lang="scss" scoped>
  .feedBack_fd1_0_c4_c01 {
    width: 160rpx;
    height: 160rpx;
    margin: 0rpx 24rpx 24rpx 0rpx;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
  }

  .feedBack_fd1_0_c4_c001 {
    width: 160rpx;
    height: 160rpx;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
  }

  .feedBack_fd1_0_c4_c000 {
    top: 0rpx;
    right: 0rpx;
    z-index: 2;
    color: #ff5536;
  }

  .feedBack_fd1_0_c4_c00 {
    margin: 0rpx 24rpx 24rpx 0rpx;
  }

  .feedBack_fd1_0_c4_c0 {
    padding: 24rpx 0rpx 0rpx 24rpx;
  }

  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: rgba(255, 255, 255, 1);
    background-size: 100% auto;
  }

  .managingpersonalInformation_flex_0 {
    background: rgba(255, 255, 255, 1);
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto;
  }

  .managingpersonalInformation_fd0_0_c2_c0 {
    width: 119rpx;
    height: 55rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .managingpersonalInformation_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333333;
    line-height: 50rpx;
  }

  .managingpersonalInformation_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .managingpersonalInformation_fd0_0_c0 {
    width: 120rpx;
  }

  .managingpersonalInformation_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .managingpersonalInformation_fd1_1_c6_c0 {
    background: rgba(37, 104, 174, 1);
    border-radius: 50rpx;
    width: 686rpx;
    line-height: 88rpx;
    font-size: 34rpx;
    color: #fff;
  }

  .managingpersonalInformation_fd1_1_c6 {
    margin: 70rpx 0rpx 0rpx 0rpx;
  }

  .managingpersonalInformation_fd1_1_c5 {
    padding: 32rpx 0rpx 32rpx 0rpx;
  }

  .managingpersonalInformation_fd1_1_c4_c1_c0_image {
    width: 200rpx;
    height: 200rpx;
  }

  .managingpersonalInformation_fd1_1_c4_c1 {
    margin: 24rpx 0rpx 0rpx 0rpx;
  }

  .managingpersonalInformation_fd1_1_c4_c0_c1 {
    color: #90949E;
    font-size: 24rpx;
    font-weight: 400;
    line-height: 32rpx;
  }

  .managingpersonalInformation_fd1_1_c4_c0_c0 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 32rpx;
    margin: 0rpx 24rpx 0rpx 0rpx;
  }

  .managingpersonalInformation_fd1_1_c0_c1 {
    margin: 24rpx 0rpx 0rpx 0rpx;
    font-size: 36rpx;
    color: rgba(16, 16, 16, 1);
  }

  .managingpersonalInformation_fd1_1_c0_c0 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 32rpx;
  }

  .managingpersonalInformation_fd1_1_c0 {
    border-bottom: 1px solid #eee;
    padding: 32rpx 0rpx 32rpx 0rpx;
  }

  .managingpersonalInformation_fd1_1 {
    padding: 16rpx 30rpx 40rpx 30rpx;
  }

  .managingpersonalInformation_fd1_0_c0 {
    color: #2568AE;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 32rpx;
  }

  .managingpersonalInformation_fd1_0 {
    background: rgba(241, 247, 253, 1);
    padding: 24rpx 32rpx 24rpx 32rpx;
    background-size: 100% auto;
  }
</style>
